<?php get_instance()->view('common/header');?>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> <?php echo $title ?> </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li><i class="fa fa-home"></i><a href="javascript:void(0);"><?php echo $title ?> </a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!--开始-->

            <div class="row">
                <div class="col-md-12">
                    <div class="portlet">
                        <div class="portlet-body">
                            <div class="table-container">
                                <div class="table-actions-wrapper"> <span> </span>
                                    <?php if(adminAuthority('bank-add', 'fund')):?>
                                    <a class="btn btn-sm blue add-btn" href="javascript:;"><i class="fa fa-plus"></i> 新增</a>
                                     <?php endif;?>
                                </div>
                                <table class="table table-bordered table-hover scoll-title" id="datatable">
                                    <thead>
                                    <tr role="row" class="heading">
                                        <th width="50px" sort="false">ID</th>
                                        <th width="50px" sort="false">LOGO</th>
                                        <th sort="false"> 银行名称 </th>
                                        <th width="200px" sort="false">操作</th>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <th></th>
                                        <th><input class="form-control form-filter input-sm" name="bank_name" type="text"></th>
                                        <th> <div class="btn-group">
                                                <a class="btn btn-xs filter-submit btn-default">
                                                    <i class="fa fa-search"></i> 搜索
                                                </a>
                                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                <ul role="menu" class="dropdown-menu pull-right">
                                                    <li>
                                                        <a href="javascript:void(0);" class="filter-cancel">重置</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--结束-->
        </div>
    </div>
</div>

<div id="save-modal" style="top: 20%;" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('fund/bank/save');?>" class="form-horizontal" id="save-form" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">银行名称<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required" name="bank_name" type="text"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">LOGO<span class="required">*</span></label>
                        <div class="col-md-6">
                            <div class="cropitMaster-box" style="width:124px;height:124px;&quot;">
                                <img class="icon" style="width:100%;height:100%;" id="icn-img" alt="" src="">
                            </div>
                            <a class="upload-btn" href="javascript:void(0);">选择上传图片（76*76）</a>
                            <input type="hidden" name="bank_icon" id="pic" >
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id"/>
                    <button class="btn green">保存</button>
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var model = $('#save-modal');

        $(".add-btn").live('click',function () {
            var defaultImg = '<?php echo getDefaultImg()?>';
            model.find('.modal-title').html('添加银行' );
            model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
            model.find('.show_message_error').remove();
            model.find('input').val('');
            model.find('img').attr('src', defaultImg);
            model.modal();
        });

        $('.edit-btn').live('click', function(){
            var id = $(this).attr('data-id');
            l_blockUI();
            $.ajax('<?php echo getUrl('fund/bank/getInfo')?>', {
                dataType:'json',
                data:{id:id},
                type:'post',
                error:function(){
                    show_message({status:0, info:'请求超时'});
                    App.unblockUI();
                },
                timeout:60000,
                success:function(data,textStatus,jqXHR){
                    if(!data){
                        show_message({status:0, info:'请求超时'});
                        return;
                    }
                    console.log(data.data.bank_icon.og);
                    model.find('.modal-title').html('编辑银行 - '+data.data.bank_name );
                    model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                    model.find('.show_message_error').remove();
                    model.find('.icon').attr('src', data.data.bank_icon.og);
                    model.find('[name="bank_name"]').val(data.data.bank_name);
                    model.find('[name="id"]').val(data.data.id);
                    model.modal();
                    App.unblockUI();
                }
            });
            return false;
        });
        cropitMaster({
            uploadBtn:$('.upload-btn'),
            height:'78px',
            width:'78px',
            complete:function(btn,data){
                $('#icn-img').attr('src', data);
                $('#pic').val(data).change();
            }
        });
        $.e_validate.init('#save-form',{modal:model,ignore:''});
    });
</script>
<script type="text/javascript">
    $(function(){
        datatable_init({
            src: $("#datatable"),
            sAjaxSource: "<?php echo getUrl('fund/bank/getList');?>",
            bSort:false
        });
    });
</script>
</body>
</html>